home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / MacApp Documentation / MacApp AppleLink Messages / MacApp.Tech$ 3⁄30⁄90 / 0985-Re Getting Control?-Mar90 < prev    next >
Encoding:
Text File  |  1990-03-30  |  1.4 KB  |  56 lines  |  [TEXT/GEOL]

  1. Item    6495376                         26-March-90        10:39PST
  2.  
  3. From:   KEMINK1                         Kemink, Joost
  4.  
  5. To:     CHANDLER1                       Chandler, Dick
  6.  
  7. cc:     MACAPP.TECH$                    MacApp Technical
  8.  
  9. Sub:    Re-Getting Control?
  10.  
  11. Dick,
  12.  
  13. You could create an event handler for each serial buffer. Such a handler's
  14. DoIdle method could then check for data in the buffer and take appropriate
  15. action. Something like this:
  16.  
  17. TBufferWatcher = OBJECT (TEvtHandler)
  18.   PROCEDURE TBufferWatcher.Free; OVERRIDE;
  19.    PROCEDURE TBufferWatcher.IBufferWatcher;
  20.    FUNCTION  TBufferWatcher.DoIdle(phase:IdlePhase):BOOLEAN; OVERRIDE;
  21. END;
  22.  
  23. FUNCTION TBufferWatcher.DoIdle(phase:IdlePhase):BOOLEAN; OVERRIDE;
  24. BEGIN
  25.     { • Check for bytes in the serial buffer and take action if there are }
  26.  
  27.     DoIdle:=FALSE;
  28. END;
  29.  
  30. PROCEDURE TBufferWatcher.IBufferWatcher;
  31. BEGIN
  32.    SELF.IEvtHandler(NIL);
  33.  
  34.   { • Check at most every second }
  35.    SELF.SetIdleFreq(60);
  36.  
  37.   { • Attach the buffer to be watched to SELF, for example by assigning it to
  38.         one of SELF's fields }
  39.  
  40.   { • Instal the event handler in the cohandler chain }
  41.    gApplication.InstallCohandler(SELF,TRUE);
  42. END;
  43.  
  44. PROCEDURE TBufferWatcher.Free; OVERRIDE;
  45. BEGIN
  46.   { • Remove the event handler from the cohandler chain }
  47.    gApplication.InstallCohandler(SELF,FALSE);
  48.  
  49.    INHERITED Free;
  50. END;
  51.  
  52. Hope this helps,
  53.  
  54. Joost Kemink
  55.  
  56.